<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>简易笔记本用户登录</title>
        <style type="text/css">
            .red {
                color: #FF0000
            }
        </style>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link href="http://apps.bdimg.com/libs/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet"/>
        <script src="http://apps.bdimg.com/libs/jquery/2.0.0/jquery.min.js"></script>
        <script src="http://apps.bdimg.com/libs/bootstrap/3.3.0/js/bootstrap.min.js"></script>
		<link href="/button/button.css" rel="stylesheet"/>
        <script>
            /**
             *注册热键enter,触发登录操作
             */
            document.onkeydown = function(event){
                var e = event || window.event || arguments.callee.caller.arguments[0];
                if (e && e.keyCode == 13) {
                    $.post("/login", {
                        "simnote.userName": $("#userName").val(),
                        "simnote.passWord": $("#passWord").val()
                    }, function(data, status){
                        if (data.info == "sucess") {
                            window.location.assign("/userInterface");
                        }
                        else {
                            var msg = data.info;
                            alert(msg);
                        }
                    });
                }
            };
            /**
             *注册的异步请求
             */
            $(document).ready(function(){
                $("#register").click(function(){
                    $.post("/register", {
                        "simnote.userName": $("#userName").val(),
                        "simnote.passWord": $("#passWord").val(),
                        "simnote.deviceType": 10000000//指定web端注册定义的标示
                    }, function(data, status){
                        if (data.info == "sucess") {
                            alert("注册成功");
                        }
                        else {
                            var msg = data.info;
                            alert(msg);
                        }
                    },"json");
                });
                /**
                 *登陆的异步请求
                 */
                $("#login").click(function(){
                    $.post("/login", {
                        "simnote.userName": $("#userName").val(),
                        "simnote.passWord": $("#passWord").val()
                    }, function(data, status){
                        if (data.info == "sucess") {
                            window.location.assign("/userInterface");
                        }
                        else {
                            var msg = data.info;
                            alert(msg);
                        }
                    });
                });
               });
        </script>
    </head>
    <body>
        <h1>简易笔记本用户登录</h1>
        <form method="post">
            <div class="form-group">
                <label for="用户名">用户名</label>
                <input id="userName" type="text" name="simnote.userName" value="zhouhao" class="form-control" placeholder="用户名是1~12为的数字或者字母">
            </div>
            <div class="form-group">
                <label for="密码">密码</label>
                <input id="passWord" type="password" name="simnote.passWord" value="871020" class="form-control" placeholder="密码设置必须为6位">
            </div>
        </form>
		<div class="container"/>
			<div class="row">
				<div class="col-xs-6"/>
					<button type="submit" id="register" name="register" class="button button-glow button-rounded button-raised button-primary">注册</button>
				</div>
				<div class="col-xs-6"/>
					<button type="submit" id="login" name="login" class="button button-glow button-rounded button-raised button-primary">登录</button>
				</div>
			</div>
		</div>
    </body>
</html>



